<?php

$basedir = dirname(__FILE__);

require_once $basedir . '/../../../../extlib/Crypt/RSA.php';
require_once $basedir . '/../../../../extlib/Crypt/Random.php';
require_once $basedir . '/../../../../extlib/Crypt/Hash.php';
require_once $basedir . '/../../../../extlib/Math/BigInteger.php';

require_once $basedir . '/../../../../classes/magic.php';
require_once $basedir . '/../../../../classes/magic/signature/keygenerator.php';

class Magic_Signature_KeyGeneratorTest extends PHPUnit_Framework_TestCase {
    
    public function testConstructorOfMagicSignaturGeneratorObject() {
        $object = new Magic_Signature_KeyGenerator();
        $this->assertEquals("Magic_Signature_KeyGenerator", get_class($object));
    }
    
    public function testGenerationOfKeys() {
        $object = new Magic_Signature_KeyGenerator();
        $object->generatePublicKeyPrivateKey();
        $privateKey = $object->privateKeyAsString();
        $publicKey = $object->publicKeyAsString();
        
        $this->assertEquals('RSA.', substr($privateKey, 0,4));
        $this->assertEquals(354, strlen($privateKey));
        
        $this->assertEquals('RSA.', substr($publicKey, 0,4));
        $this->assertEquals(181, strlen($publicKey));
        
//        echo "\n" . $privateKey;
//        echo "\n" . $publicKey;
        
    }
}